import { forwardRef } from "react";
import "./Timer.css";
import useTimer from "./useTimer";

function Timer({ seconds, onDone }, compRef) {
    const { millisecond } = useTimer(compRef, seconds, onDone);

    return (
        <div className="timer monospace">
            <div className="integer">{`${Math.floor(millisecond / 1000)}`}</div>
            <div className="seperator">.</div>
            <div className="fraction">
                {`${Math.floor((millisecond % 1000) / 100)}`}
            </div>
        </div>
    );
}

export default forwardRef(Timer);
